//
//  PushJobTableViewCell.m
//  Liuhe
//
//  Created by zr on 2018/8/10.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "PushJobTableViewCell.h"

@interface PushJobTableViewCell ()

@property (nonatomic, weak)UITextField * textFiled;
@property (nonatomic, weak)UIImageView * rightImageView;
@property (nonatomic, weak)UIView * lineView;

@end

@implementation PushJobTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}



- (void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor whiteColor];
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.textColor = ColorWithRGB(0x808080);
    titleLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    
    self.titleLabel = titleLabel;
    
    [self.contentView addSubview:self.titleLabel];
    
    
    UIImageView * rightImageView = [UIImageView new];
    
    rightImageView.image = ImageNamed(@"fh222");
    
    self.rightImageView = rightImageView;
    
    [self.contentView addSubview:self.rightImageView];
    
    
    UITextField * textFiled = [[UITextField alloc] init];
    
    textFiled.borderStyle = UITextBorderStyleNone;
    textFiled.backgroundColor = [UIColor whiteColor];
    //设置光标颜色
    textFiled.tintColor = BLACK_COLOR;
    //修改占位符文字颜色
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = ColorWithRGB(0xB3B3B3);
    attrs[NSFontAttributeName] = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
//    attrs[]
    textFiled.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"未填写" attributes:attrs];
    textFiled.textColor = BLACK_COLOR;
    textFiled.textAlignment = NSTextAlignmentRight;
    textFiled.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    //    accountText.keyboardAppearance = UIKeyboardAppearanceDark;
     [textFiled addTarget:self action:@selector(textfieldTextDidChange:) forControlEvents:UIControlEventEditingDidEnd];
    
    self.textFiled = textFiled;
    
    [self.contentView addSubview:self.textFiled];
    
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0xe6e6e6);
    
    self.lineView = lineView;
    
    [self.contentView addSubview:self.lineView];

}

#pragma mark - private method
- (void)textfieldTextDidChange:(UITextField *)textField
{
    self.block(textField.text);
}


-(void)layoutSubviews{
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
    }];
    
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.contentView).offset(-15 * SCREENH6);
        make.centerY.mas_equalTo(self.contentView);
        make.height.mas_equalTo(15 * SCREENH6);
        make.width.mas_equalTo(8 * SCREENH6);
    }];
    
    [self.textFiled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.rightImageView.mas_leading).offset(-10 * SCREENH6);
        make.centerY.mas_equalTo(self.contentView);
        make.height.mas_equalTo(30 * SCREENH6);
        make.leading.mas_equalTo(self.titleLabel.mas_trailing).offset(10 * SCREENH6);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.mas_equalTo(self.contentView);
        make.height.mas_equalTo(1 * SCREENH6);
        make.bottom.mas_equalTo(self.contentView);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
